package edu.pku.sei.transformation.editor.XML;

import java.io.File;

import edu.pku.sei.modeler.exceptions.FactoryNotFoundException;
import edu.pku.sei.modeler.model.common.ModelRegistry;
import edu.pku.sei.modeler.model.core.MetaModel;
import edu.pku.sei.transformation.editor.model.ModelFactory;

public abstract class AbstractXMILoader {
	protected File xmiFile;
	protected MetaModel projectModel;
	protected ModelFactory factory;

	public AbstractXMILoader(String fileAddress, MetaModel projectModel) {
		xmiFile = new File(fileAddress);
		this.projectModel = projectModel;
		try {
			this.factory = (ModelFactory) ModelRegistry.getRegistry()
					.getFactory(projectModel);
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FactoryNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public AbstractXMILoader(File file, MetaModel projectModel) {
		this.xmiFile = file;
		this.projectModel = projectModel;
		try {
			this.factory = (ModelFactory) ModelRegistry.getRegistry()
					.getFactory(projectModel);
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FactoryNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	abstract public MetaModel getModel();
}
